package com.zsc.wxm.ysh.anjo.es.controller;

import com.zsc.wxm.ysh.anjo.es.service.SearchService;
import com.zsc.wxm.ysh.anjo.result.PageResult;
import com.zsc.wxm.ysh.anjo.service.base.model.es.qo.SearchQuery;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * 描述：
 *
 * @author playmaker
 * @since 2021/2/15 19:26
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Resource
    private SearchService searchService;

    @PostMapping("/data")
    @ApiOperation("检索房源数据")
    public PageResult searchData(@RequestBody SearchQuery params) {
        return searchService.searchHouseResources(params);
    }


    @PostMapping("/home-recommend")
    @ApiOperation("房源首页推荐，默认每页10条数据")
    public PageResult homeRecommend(@RequestParam(value = "province",required = false) @ApiParam("省份") String province,
                                    @RequestParam(value = "city", required = false) @ApiParam("城市") String city,
                                    @RequestParam("currPage") @ApiParam("页码") Integer currPage) throws ParseException {
        return searchService.homeRecommend(province, city, currPage);
    }
}
